import { MessageBox } from 'element-ui'
import router from '../../router'
export class ServerError500 extends Error {
  constructor(message) {
    message = message || '服务器异常'
    MessageBox({
      title: '提示',
      message,
      type: 'warning',
    })
    super(message)
  }
}
export class ServerError403 extends Error {
  constructor(message) {
    message = message || '您没有登陆'
    MessageBox({
      title: '提示',
      message,
      type: 'warning',
    }).then(() => {
      console.log('跳转路由')
      router.replace('login')
    })
    super(message)
  }
}
export class ServerError10400 extends Error {
  constructor(message) {
    message = message || '您没有登陆'
    MessageBox.alert(message, '提示', {
      confirmButtonText: '去登录',
      type: 'warning',
      center: true,
    }).then(() => {
      window.open('http://www.cbda1984.com/login?webUrl=' + window.location.href)
    })
    super(message)
  }
}
export class RequestError extends Error {
  constructor(message) {
    message = message || '您没有登陆'
    MessageBox({
      title: '提示',
      message,
      type: 'warning',
    })
    super(message)
  }
}
